package com.itheima.controller;

import com.itheima.config.UserProperties;
import com.itheima.service.UserService;
import com.itheima.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private UserProperties userProperties;

//    @Value("${myconfig.name}")
//    private String name;

    /***
     * 根据id查询用户详情
     */
    @GetMapping(value = "/{id}")
    public User one(@PathVariable(value = "id") Long id) {
        return userService.findById(id);
    }

    @GetMapping(value = "/name")
    public String getNacosConfig() {
        return "name:" + userProperties.getName();
    }

    @GetMapping(value = "/info")
    public String getMyInfo(@RequestHeader("MyInfo") String info) {
        return "MyInfo:" + info;
    }
}
